package io.github.ali.commons.function;

import java.util.Objects;

/**
 * 
 * @author bailey
 * @date 2022年9月6日
 * @param <T>
 * @param <U>
 * @param <E>
 */
@FunctionalInterface
public interface ThrConsumer<T, U, E> {

	void accept(T t, U u, E e) throws Exception;
	
	default ThrConsumer<T, U, E> andThen(Consumer<? super T> after) {
		Objects.requireNonNull(after);

		return (l, r, e) -> {
			accept(l, r, e);
			after.accept(l);
		};
	}
	
	default ThrConsumer<T, U, E> andThen(BiConsumer<? super T,? super U> after) {
		Objects.requireNonNull(after);

		return (l, r, e) -> {
			accept(l, r, e);
			after.accept(l,r);
		};
	}

	default ThrConsumer<T, U, E> andThen(ThrConsumer<? super T, ? super U, ? super E> after) {
		Objects.requireNonNull(after);

		return (l, r, e) -> {
			accept(l, r, e);
			after.accept(l, r, e);
		};
	}
}
